//通过身份证号计算年龄、性别、出生日期
export const idCard =(userCard, num) => {
  //获取出生日期
      if (num == 1) {
        let birth = userCard.substring(6, 10) +userCard.substring(10, 12)  + userCard.substring(12, 14);
          return birth;
      }
  //获取性别
      if (num == 2) {
          if (parseInt(userCard.substr(16, 1)) % 2 == 1) {
              return "男";
          } else {
              return "女";
          }
      }
  //获取年龄
      if (num == 3) {
          var myDate = new Date();
          var month = myDate.getMonth() + 1;
          var day = myDate.getDate();
          var age = myDate.getFullYear() - userCard.substring(6, 10) - 1;
          if (userCard.substring(10, 12) < month || userCard.substring(10, 12) == month && userCard.substring(12, 14) <= day) {
              age++;
          }
          return age;
      }
  }
